// Thin wrapper around fopen() that supports Unicode fname on all platforms.
FILE* ufopen(const QString& fname, const char* mode);
-// OS-abstracting wrapper for getting Unicode environment variables.
-QString ugetenv(const char* env_var);
-
// FIXME: case_ignore_strcmp() and case_ignore_strncmp() should probably
// just be replaced at the call sites. These shims are just here to make
// them more accommodating of QString input.
[ gdb ]
via = 1
-
-;------------------------------------------------------------------
-[ tiger ]
-snlen=7
-
-;------------------------------------------------------------------
-[pathaway]
-# dbname = The Last Trip
-deficon = Golf Course
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include "defs.h" // for fatal, ugetenv, warning
+#include "defs.h" // for fatal, warning
#include "inifile.h"
#include "src/core/file.h" // for File
#include <QByteArray> // for QByteArray
#include <QHash> // for QHash
#include <QIODevice> // for QIODevice::ReadOnly, QIODevice
#include <QTextStream> // for QTextStream
-#include <Qt> // for CaseInsensitive
-#include <QtGlobal> // for qPrintable
+#include <QtGlobal> // for qEnvironmentVariable, qPrintable, QT_VERSION, QT_VERSION_CHECK
#include <utility>
#define MYNAME "inifile"
{
QString res;
- QString envstr = ugetenv("GPSBABELINI");
+ QString envstr = qEnvironmentVariable("GPSBABELINI");
if (!envstr.isNull()) {
if (QFile(envstr).open(QIODevice::ReadOnly)) {
return envstr;
#ifdef __WIN32__
// Use &&'s early-out behaviour to try successive file locations: first
// %APPDATA%, then %WINDIR%, then %SYSTEMROOT%.
- (name = find_gpsbabel_inifile(ugetenv("APPDATA"))).isNull()
- && (name = find_gpsbabel_inifile(ugetenv("WINDIR"))).isNull()
- && (name = find_gpsbabel_inifile(ugetenv("SYSTEMROOT"))).isNull();
+ (name = find_gpsbabel_inifile(qEnvironmentVariable("APPDATA"))).isNull()
+ && (name = find_gpsbabel_inifile(qEnvironmentVariable("WINDIR"))).isNull()
+ && (name = find_gpsbabel_inifile(qEnvironmentVariable("SYSTEMROOT"))).isNull();
#else
// Use &&'s early-out behaviour to try successive file locations: first
// ~/.gpsbabel, then /usr/local/etc, then /etc.
#define HAVE_INIFILE_H
#include <QHash> // for QHash
-#include <QList> // for QList
#include <QString> // for QString
class InifileSection;
#include <cstdarg> // for va_list, va_end, va_start, va_copy
#include <cstdio> // for size_t, vsnprintf, FILE, fopen, printf, sprintf, stderr, stdin, stdout
#include <cstdint> // for uint32_t
-#include <cstdlib> // for abs, getenv, calloc, free, malloc, realloc
+#include <cstdlib> // for abs, calloc, free, malloc, realloc
#include <cstring> // for strlen, strcat, strstr, memcpy, strcmp, strcpy, strdup, strchr, strerror
#include <ctime> // for mktime, localtime
#include <QXmlStreamAttributes> // for QXmlStreamAttributes
#include <Qt> // for CaseInsensitive
#include <QTimeZone> // for QTimeZone
-#include <QtGlobal> // for qAsConst, QAddConst<>::Type, qPrintable
+#include <QtGlobal> // for qAsConst, qEnvironmentVariableIsSet, QAddConst<>::Type, qPrintable
#include "defs.h"
#include "src/core/datetime.h" // for DateTime
#endif
}
-/*
- * OS-abstracting wrapper for getting Unicode environment variables.
- */
-QString ugetenv(const char* env_var)
-{
-#ifdef __WIN32__
- // Use QString to convert 8-bit env_var argument to wchar_t* for _wgetenv().
- return QString::fromWCharArray(
- _wgetenv((const wchar_t*) QString(env_var).utf16()));
-#else
- // Everyone else uses UTF-8 or some other locale-specific 8-bit encoding.
- return QString::fromLocal8Bit(std::getenv(env_var));
-#endif
-}
-
/*
* Allocate a string using a format list with optional arguments
* Returns -1 on error.
bool
gpsbabel_testmode()
{
- static bool testmode = getenv("GPSBABEL_FREEZE_TIME") != nullptr;
+ static bool testmode = qEnvironmentVariableIsSet("GPSBABEL_FREEZE_TIME");
return testmode;
}